#include <iostream>
using namespace std;
const int P = 131, N = 1e6 + 10;
typedef unsigned long long ull;
ull h[N], p[N];
ull num;
ull query(int l, int r)
{
    return h[r] - h[l - 1] * p[r - l + 1];
}
int main()
{
    int n, m;
    string s1, s2;
    cin >> n >> s1 >> m >> s2;
    for (int i = 0; i < n; i++)
    {
        num = num * 131 + s1[i];
    }
    cout << num << endl;
    p[0] = 1;
    for (int i = 1; i <= m; i++)
    {
        p[i] = p[i - 1] * P;
        h[i] = h[i - 1] * P + s2[i];
    }
    for (int i = 0; i + n <= m; i++)
    {
        cout << query(i + 1, i + n) << ' ';
        if (num == query(i + 1, i + n))
        {
            cout << i << ' ';
        }
    }
    return 0;
}

